import copy
import os
import sys

from asset.base import *

file_path="./save"
if not os.path.exists(file_path):
    with open(file_path,"x"):...
igvar:dict=copy.deepcopy(Default)
with open(file_path,"r") as file:
    while True:
        try:
            exec("igvar="+file.read())
            if type(igvar) != dict:raise SyntaxError
            break
        except SyntaxError:
            with open(file_path,"w") as filew:
                filew.write(pycr.stringify(Default))
def save():
    with open(file_path,"w") as file:
        file.write(pycr.stringify(igvar))
def getloca():
    for d in direct_dirs:
        for suffix in support_suffix:
            p="./levels/"+d+str(igvar["location"])+suffix
            if os.path.exists(p):return p
    for suffix in support_suffix:
        p="./levels/"+str(igvar["location"])+suffix
        if os.path.exists(p):return p
    return "./levels/"+str(igvar["location"])+".lev"
def execloca()->"list[Game_Blocks]":
    loca=getloca()
    tmp:"list[list[Game_Blocks]]"=list()
    exec(open(loca,"r").read()+"\ntmp.append(__level__)\ntmp.append(__levelname__)")
    text=mltsplit(loca,'/','\\')[-1]
    pygame.display.set_caption(text)
    return tmp[0],tmp[1]
